package datastructure.string;

/**
 *
 *
 * @author Lei
 */
public class PermutationString {

    public static void permutation(String prefix, String inputString) {

        int n = inputString.length();
        if (n == 0) {
            System.out.println(prefix);
        }
        else {
            for (int i = 0; i < n; i++) {
                permutation(prefix + inputString.charAt(i), inputString.substring(0, i) + inputString.substring(i + 1, n));
            }
        }
    }

    public static void permutationString(String inputString) {
        permutation("", inputString);
    }
    
    public static void main(String[] args) {
        permutationString("main");
    }
    
}
